package com.blog;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

/**
 * @className: Save
 * @description: 
 * @author: HCl
 * @createTime: 2020��5��24�� ����9:37:05
 */
public class Save {
	public static void savePic(String str01, String fileName) {
		InputStream inputStream=new ByteArrayInputStream(str01.getBytes());

        OutputStream os = null;
        try {
            String path = "D:\\environment\\apache\\apache-tomcat-9.0.27\\webapps\\appdate\\blog\\test\\";
            // 2�����浽��ʱ�ļ�
            // 1K�����ݻ���
            byte[] bs = new byte[102400];
            // ��ȡ�������ݳ���
            int len;
            // ������ļ������浽�����ļ�

            File tempFile = new File(path);
            if (!tempFile.exists()) {
                tempFile.mkdirs();
            }
            os = new FileOutputStream(tempFile.getPath() + File.separator + fileName);
            // ��ʼ��ȡ
            while ((len = inputStream.read(bs)) != -1) {
                os.write(bs, 0, len);
            }

        } catch (IOException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            // ��ϣ��ر���������
            try {
                os.close();
                inputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

}
